package com.sushi.dao;

import com.sushi.pojo.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BookDao {
    @Select("SELECT * FROM book")
    List<Book> findAll();
    @Select("SELECT * FROM book WHERE id = #{id}")
    Book findById(Integer id);
    @Select("INSERT INTO book (type, name, description) VALUES (#{type}, #{name}, #{description})")
    void save(Book book);
    @Delete("DELETE FROM book WHERE id = #{id}")
    int deleteById(Integer id);
    @Update("UPDATE book SET type = #{type}, name = #{name}, description = #{description} WHERE id = #{id}")
    int update(Book book);

}
